package com.sptpc.demo.support;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;

import java.io.IOException;
import java.time.LocalDate;

public class LocalDateDeserializer extends StdDeserializer<LocalDate> {

    protected LocalDateDeserializer(StdDeserializer<?> src) {
        super(src);
    }

    @Override
    public LocalDate deserialize(JsonParser jsonParser,
                                 DeserializationContext deserializationContext)
            throws IOException, JacksonException {
        return LocalDate.of(jsonParser.getValueAsInt(),
                jsonParser.getValueAsInt(),jsonParser.getValueAsInt());
    }

}
